<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <!-- 用户 -->
    <div class="layui-form-item">
        <label class="layui-form-label required">用户名</label>
        <div class="layui-input-block">
            <input type="text" name="username" lay-verify="username" lay-reqtext="用户名不能为空" placeholder="请输入用户名" value="" class="layui-input">
            <tip>字母数字组合，开头是字母，3-15个字符</tip>
        </div>
    </div>
    <!-- 密码 -->
    <div class="layui-form-item">
        <label class="layui-form-label required">密码</label>
        <div class="layui-input-block">
            <input type="password" name="password" lay-verify="required" lay-reqtext="密码不能为空" placeholder="请输入密码" value="123456" class="layui-input">
            <tip>默认密码为123456</tip>
        </div>
    </div>
    <!-- 角色 -->
    <div class="layui-form-item">
        <label class="layui-form-label">角色</label>
        <div class="layui-input-block">
            <select name="interest" lay-filter="role">
                <option value=""></option>
                <option value="1">超级管理员</option>
                <option value="2">管理员</option>
                <option value="3" selected>普通用户</option>
            </select>
            <tip>选择你的账号身份</tip>
        </div>
    </div>
    <!--启用状态 -->
    <div class="layui-form-item">
        <label class="layui-form-label required">启动状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="启用" checked="">
            <input type="radio" name="status" value="0" title="禁用">
        </div>
    </div>
    <!-- 真实姓名-->
    <div class="layui-form-item">
        <label class="layui-form-label required">真实姓名</label>
        <div class="layui-input-block">
            <input type="text" name="realname" lay-verify="required" lay-reqtext="姓名不能为空" placeholder="请输入真实姓名" value="" class="layui-input" required>
            <tip>2-5 个汉字，必填</tip>
        </div>
    </div>
    <!-- 院系 -->
    <div class="layui-form-item">
        <label class="layui-form-label">院系</label>
        <div class="layui-input-block">
            <select name="college" lay-filter="college">
                <option value=""></option>
                <option value="1">计算机科学与技术学院</option>
                <option value="2">机械学院</option>
                <option value="3">化学学院</option>
            </select>
        </div>
    </div>
    <!-- 专业 -->
    <div class="layui-form-item">
        <label class="layui-form-label">专业</label>
        <div class="layui-input-block">
            <select name="major" lay-filter="major">
                <option value=""></option>
                <option value="1">计算机科学与技术</option>
                <option value="2">软件工程</option>
                <option value="3" selected>智能科学与技术</option>
            </select>
        </div>
    </div>
    <!-- 班级 -->
    <div class="layui-form-item">
        <label class="layui-form-label">班级</label>
        <div class="layui-input-block">
            <select name="class" lay-filter="class">
                <option value=""></option>
                <option value="1">计算机一班</option>
                <option value="2">计算机二班</option>
                <option value="3">计算机三班</option>
            </select>
        </div>
    </div>
    <!-- 入学年份 -->
    <div class="layui-form-item">
        <label class="layui-form-label required">入学年份</label>
        <div class="layui-input-block">
            <input id="date" type="text" name="year" lay-verify="required"  placeholder="请选择入学年份" value="" class="layui-input" readonly>
        </div>
    </div>
    <!-- 校内职务 -->
    <div class="layui-form-item">
        <label class="layui-form-label required">校内职务</label>
        <div class="layui-input-block">
            <input type="text" name="username"  placeholder="请输入校内职务" value="" class="layui-input">
        </div>
    </div>
    <!-- 手机号码 -->
    <div class="layui-form-item">
        <label class="layui-form-label required">手机</label>
        <div class="layui-input-block">
            <input type="number" name="phone" lay-verify="required" lay-reqtext="手机不能为空" placeholder="请输入手机号码" value="" class="layui-input">
        </div>
    </div>
    <!-- qq号码 -->
    <div class="layui-form-item">
        <label class="layui-form-label">QQ</label>
        <div class="layui-input-block">
            <input type="qq" name="qq" placeholder="请输入QQ" value="" class="layui-input">
        </div>
    </div>
    <!-- 备注 -->
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">备注信息</label>
        <div class="layui-input-block">
            <textarea name="remark" class="layui-textarea" placeholder="请输入备注信息"></textarea>
        </div>
    </div>
    <!-- 确认保存 -->
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script src="../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use('form', function(){
        var form = layui.form;

        form.verify({

            //用户名-函数
            username: function(value, item){ //value：表单的值、item：表单的DOM对象
                if(!new RegExp("^[a-zA-Z0-9_\u4e00-\u9fa5\\s·]+$").test(value)){
                    return '用户名不能有特殊字符';
                }
                if(/(^\_)|(\__)|(\_+$)/.test(value)){
                    return '用户名首尾不能出现下划线\'_\'';
                }
                if(/^\d+\d+\d$/.test(value)){
                    return '用户名不能全为数字';
                }
            }

            //密码-正则
            ,pass: [
                /^[\S]{6,12}$/
                ,'密码必须6到12位，且不能出现空格'
            ]
        });


    });
</script>
<script>
    layui.use(['form','laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            laydate = layui.laydate
            $ = layui.$;
            //年选择器
            laydate.render({
                elem: '#date'
                ,type: 'year',
                max:'2021',
        });

        //监听提交
        form.on('submit(saveBtn)', function (data) {
            var index = layer.alert(JSON.stringify(data.field), {
                title: '最终的提交信息'
            }, function () {

                // 关闭弹出层
                layer.close(index);

                var iframeIndex = parent.layer.getFrameIndex(window.name);
                parent.layer.close(iframeIndex);

            });

            return false;
        });

    });
</script>
</body>
</html>